package Events.gui;

import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

import Events.StartGameEvent;
import Professions.Commander;
import Professions.Engineer;
import Professions.MadScientist;
import Professions.Medic;
import Professions.Profession;

public class SetupPlayerTemp extends JPanel implements MouseListener{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JButton next;//, cancel;
	private JComboBox cmbProf;
	private JLabel lblPname, lblProf;
	private JTextField txtPname;
	
	private StartGameEvent sge;
	/**
	 * Create the panel.
	 */
	public SetupPlayerTemp(StartGameEvent sge) {
		super();
		this.sge = sge;
		setLayout(null);
		this.setPreferredSize(new Dimension(600,500));
		lblPname = new JLabel("Player Name:");
		lblPname.setHorizontalAlignment(SwingConstants.RIGHT);
		lblPname.setBounds(83, 56, 117, 14);
		add(lblPname);
		
		txtPname = new JTextField();
		txtPname.setBounds(210, 53, 226, 20);
		txtPname.setColumns(10);
		add(txtPname);
		
		lblProf = new JLabel("Enter Profession:");
		lblProf.setHorizontalAlignment(SwingConstants.RIGHT);
		lblProf.setBounds(63, 84, 137, 14);
		add(lblProf);
		
		cmbProf = new JComboBox();
		cmbProf.setBounds(210, 81, 226, 20);
		cmbProf.addItem(new Commander());
		cmbProf.addItem(new Engineer());
		cmbProf.addItem(new MadScientist());
		cmbProf.addItem(new Medic());
		add(cmbProf);
		
		next = new JButton("Next");
		next.setBounds(172, 282, 89, 23);
		next.addMouseListener(this);
		add(next);
		
		//cancel = new JButton("Cancel");
		//cancel.setBounds(285, 282, 89, 23);
		//add(cancel);
	}
	
	@Override
	public void mouseClicked(MouseEvent e) {
		if(e.getSource() == next){
			if(!txtPname.getText().equals("")){
				sge.createPlayer(txtPname.getText(), (Profession)(cmbProf.getSelectedItem()));
			}
		}
		//else if(e.getSource() == cancel){
			
		//}
	}
	@Override
	public void mouseEntered(MouseEvent e) {
	}
	@Override
	public void mouseExited(MouseEvent e) {
	}
	@Override
	public void mousePressed(MouseEvent e) {
	}
	@Override
	public void mouseReleased(MouseEvent e) {
	}
}
